import time

from Base.Base import Base
from selenium.webdriver.common.by import By
class Page(Base):

    # （2）用第一种方法找到搜素框
    select_01_loc = (By.XPATH,'//*[@id="input"]')
    def select_01(self):
        # 输入“我在做软件测试”
        self.send_keys(self.select_01_loc,'我在做软件测试')
    # （3）用第二种方法找到搜素框
    select_02_loc = (By.ID,'input')
    def select_02(self):
        self.send_keys(self.select_02_loc,'我在做软件测试')

    ck_loc = (By.XPATH,'//*[@id="search-button"]')
    def ck(self):
        self.click(self.ck_loc)

    dy1_loc = (By.XPATH,'//*[@id="keyword"]')
    def dy1(self):
        return self.text(self.dy1_loc)

    wz_loc = (By.ID,'e_idea_pp')
    def wz(self):
        return self.text(self.wz_loc)

    ck_2_loc = (By.ID,'snext')
    def ck_2(self):
        self.click(self.ck_2_loc)
        print('第二页')

    wz2_loc = (By.ID, 'main')

    def wz2(self):
        return self.text(self.wz2_loc)

    def search_360_01(self):
        self.open_url('https://www.so.com/')
        time.sleep(5)
        self.select_01()
        self.ck()
        time.sleep(3)
        print(self.dy1())
        try:
            assert '我在做软件测试' == self.dy1()
        except:
            self.driver.save_screenshot('a.png')
        print(self.wz())
        self.ck_2()
        time.sleep(5)
        print(self.wz2())


